clear all
set more off
cap log close

ssc install unique
    
global dir "/Replication Archive"
cd "${dir}"

global outreg_settings = " label bdec(4) pvalue pdec(3) tex(frag) excel  nor2 nonotes "


************************************
************* TABLE A4 *************
************************************

use "${dir}/Data/Final Datasets/Final_Data_Director_MC_Level_DEF2.dta", clear

gen donated=(amount_noself>0)
replace donated=donated*1000

unique CompanyID
local unique_company: display %5.4fc `r(unique)' 

unique DirectorID 
local unique_directors: display %5.4fc `r(unique)' 
unique icpsr2 
local unique_MC: display %5.4fc `r(unique)' 

egen double Director_MC=group(DirectorID icpsr2 chamber)
egen double Director_Company_MC=group(DirectorID CompanyID icpsr2 chamber)
egen double Congress_MC=group(icpsr2 chamber cycle)
egen double Congress_Director_Company=group(DirectorID CompanyID cycle chamber)

reghdfe donated relevant, noabsorb cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA4", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons

reghdfe donated relevant, absorb(Director_Company_MC) cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA4", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons

reghdfe donated relevant, absorb(Director_Company_MC Congress_MC) cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA4", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons

reghdfe donated relevant, absorb(Director_Company_MC Congress_MC Congress_Director_Company) cluster(Director_MC) keepsingletons
su donated if relevant ==0 & e(sample)==1, d
local mean: display %5.4fc `r(mean)' 
local effect = _b[relevant]/`mean'*100
local effect: display %5.4fc `effect'
outreg2 using "${dir}/Results/TableA4", $outreg_settings addtext(Mean, `mean', Increase, `effect', Num. Individuals, `unique_directors', Num. Companies, `unique_company', Num. MCs, `unique_MC', Individual-MC FE, No, MC-Cycle FE, No, Individual-Cycle FE, No)  nocons
